<template xmlns:el-col="http://www.w3.org/1999/html">
    <el-form ref="oneModelForm" :rules="oneModelFormRules" :model="oneModelForm" label-width="200px">
        <el-row>
            <el-col :span="16">
                <el-form-item  label="髋关节屈伸" prop="assHip">
                    <el-input type="number" v-model="oneModelForm.assHipMin" style="width: 30%"></el-input>&nbsp;&nbsp;°
                    --
                    <el-input type="number" v-model="oneModelForm.assHipMax" style="width: 30%"></el-input>&nbsp;&nbsp;°(0°~70°)
                </el-form-item>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="16">
                <el-form-item  label="膝关节屈伸" prop="assKnee">
                    <el-input type="number" v-model="oneModelForm.assKneeMin" style="width: 30%"></el-input>&nbsp;&nbsp;°
                    --
                    <el-input type="number" v-model="oneModelForm.assKneeMax" style="width: 30%"></el-input>&nbsp;&nbsp;°(0°~90°)
                </el-form-item>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="16">
                <el-form-item  label="踝关节背屈跖屈" prop="assAnkle">
                    <el-input type="number" v-model="oneModelForm.assAnkleMin" style="width: 30%"></el-input>&nbsp;&nbsp;°
                    --
                    <el-input type="number" v-model="oneModelForm.assAnkleMax" style="width: 30%"></el-input>&nbsp;&nbsp;°(-30°~30°)
                </el-form-item>
            </el-col>
        </el-row>
        <el-button  style="margin-left: 240px" type="primary" v-on:click="save">保 存</el-button>
    </el-form>
</template>

<script>
    export default {
        name: 'patient',
        data() {
            return {
                oneModelForm:{
                    assHipMin:"0",
                    assHipMax:"70",
                    assKneeMin:"0",
                    assKneeMax:"90",
                    assAnkleMin:"-30",
                    assAnkleMax:"30",
                },
                oneModelFormRules:{
                    assHipMin: [
                        { required: true, message: '请填写髋关节屈伸角度完整', trigger: 'blur' },
                    ],
                    assHipMax: [
                        { required: true, message: '请填写髋关节屈伸角度完整', trigger: 'blur' },
                    ],
                    assKneeMin: [
                        { required: true, message: '请填写膝关节屈伸角度完整', trigger: 'blur' },
                    ],
                    assKneeMax: [
                        { required: true, message: '请填写膝关节屈伸角度完整', trigger: 'blur' },
                    ],
                    assAnkleMin: [
                        { required: true, message: '请填写踝关节背屈跖屈角度完整', trigger: 'blur' },
                    ],
                    assAnkleMax: [
                        { required: true, message: '请填写踝关节背屈跖屈角度完整', trigger: 'blur' },
                    ],
                }
            }
        },
        props:['name'],
        methods: {
            save:function () {
                this.$refs['oneModelForm'].validate((valid) => {
                    if (valid) {//必填项已填写
                        console.log("第一个的评估结果：",this.oneModelForm);
                        const result=[];
                        //判断角度是否在一个范围之内，并且最小值比最大值小
                        //髋关节
                        if (this.oneModelForm.assHipMin < 0 || this.oneModelForm.assHipMax > 70 ||  (this.oneModelForm.assHipMax<=this.oneModelForm.assHipMin)){
                            result.push("1");
                            this.$message.error("髋关节验证不通过");
                            return;
                        };
                        //膝关节
                        if (this.oneModelForm.assKneeMin < 0 || this.oneModelForm.assKneeMax > 90  || (this.oneModelForm.assKneeMax<=this.oneModelForm.assKneeMin)){
                            result.push("2");
                            this.$message.error("膝关节验证不通过");
                            return;
                        };
                        //踝关节
                        if (this.oneModelForm.assAnkleMin < -30 || this.oneModelForm.assAnkleMax > 30  || (this.oneModelForm.assAnkleMax<=this.oneModelForm.assAnkleMin)){
                            result.push("3");
                            this.$message.error("踝关节验证不通过");
                            return;
                        }
                        if (result.length<=0){//验证通过
                            this.oneModelForm.name = this.name;
                            console.log("this.oneModelForm",this.oneModelForm);
                            this.$emit('assessformData', this.oneModelForm);
                            this.$message.success("保存成功");
                        }

                    }
                });
            }
        },
        watch:{     //监听value的变化，进行相应的操作即可
            name: function(a,b){     //a是value的新值，b是旧值
               this.name=a;
            }
        },
        };

</script>
<style scoped>
</style>
